# a = [1, 2, 3, 4]
# b = 2
# c = a.copy()
# a[0] = 9
# print(a, c)
#
#
# class lei:
#     age = 18  # 属性
#
#     def eat(self,name):  #实例方法
#         self.name = name
#         lei.age += 1
#
# shuhao = lei()
# shuhao.eat("书豪")
# print(shuhao.name)
# yongkang = lei()
# yongkang.eat("永康")
# print(yongkang.name)
# print(shuhao.age)
# print(yongkang.age)
class gongju:
    __i = 0
    def chuizi(self,czname):
        self.czname = czname
        gongju.__i += 1
    def banshou(self,bsname):
        self.bsname = bsname
        gongju.__i += 1
    def geti(self):
        return gongju.__i
chuizi = gongju()
chuizi.chuizi("锤子！")
print(chuizi.czname)
chuizi.banshou("扳手!")
print(chuizi.bsname)
print(f"实例化了{chuizi.geti()}个对象")

# from datetime import datetime


# class stu:
#     role = '学生'     #类属性
#     def __init__(self,name,age):
#         self.name = name    #对象属性
#         self.age = age      #对象属性
#     def get_name(self):     #实例方法，self代表实例本身
#         return self.name
#     @classmethod
#     def get_class_role(cls):    #类方法，cls代表当前类名
#         return cls.role
#     @staticmethod
#     def get_datetime():     #静态方法，与类和对象都无关

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def get_name(self):
        """获取姓名"""
        return self.name

    def get_age(self):
        """获取年龄"""
        return self.age
class Student(Person):
    def get_name(self):
        return '学生：' + self.name
class Staff(Person):
    def get_name(self):
        return '职员：' + self.name
std = Student('张三', 21)
print(std.get_name())
print(super(Student, std).get_name())
sta = Staff('李四', 32)
print(sta.get_name())

class Animal:
    def __init__(self,name):
        self.name = name
    def speak(self):
        pass
class Dog(Animal):
    def speak(self):
        return "Woof！"
class Cat(Animal):
    def speak(self):
        return "Meow！"
def animal_speak(animal):
    print(animal.speak())
dog = Dog("Rufus")
cat = Cat("Fluffy")
animal_speak(dog)
animal_speak(cat)
